<template>
	<div>
		<div class="graybg">

		</div>
		<div class="header header_bg">
			<div class="header_left">
				<i onclick="javascript:history.back(-1)" class="iconfont baiColor">&#xe612;</i>
			</div>
			<div class="header_center">
				<span class="baiColor">修改密码</span>
			</div>
		</div>

		<div class="center">
			<form action="" method="post" style="padding-top: 47px;">
				<input type="password" name="oldpass" placeholder="旧密码" v-model="oldpass" value="" />
				<input type="password" name="newpass" placeholder="新密码" v-model="newpass" value="" />
				<button @click="updatepass($event)">确定</button>
			</form>
		</div>

	</div>

</template>

<script>
	export default {
		data() {
			return {
				oldpass: '',	//旧密码
				newpass: '',	//新密码

			}
		},
		methods: {
			updatepass: function(ev) {
				ev.preventDefault();
				var _this = this;
				var oldpass = _this.oldpass;
				var newpass = _this.newpass;
				if(oldpass == newpass){
					alert("旧密码与新密码不能相同")
				}else if(oldpass == "" || newpass == ""){
					alert("信息不能为空")
				}else if(oldpass != newpass){
					let _this = this;
					var info = window.localStorage.data;
					var params = new URLSearchParams();
					params.append('token', info);	//客户秘钥（信息）
					params.append('y_pwd',oldpass);
					params.append('n_pwd',newpass);
					this.$axios({
					   url:"One/My/amendPwd",
						method:"post",
						data:params
					  }).then(function(res){
					  	if(res.data.status == 1){
					  		alert("密码修改成功")
					  	}else{
					  		alert("密码修改失败，请重新修改")
					  	}
					}).catch(function(err){
						console.log(err)		
					})
				}
				
			}
		},
	}
</script>

<style scoped="scoped">
	@import "../css/public.css";
	.center {
		width: 95%;
		margin: 0 auto;
	}
	
	.center form {
		width: 100%;
	}
	
	.center form input {
		padding: 12px 0px;
		padding-left: 10px;
		display: block;
		background: #FFFFFF;
		/*height: 14px;*/
		width: 97%;
		margin-bottom: 2px;
	}
	
	input::-webkit-input-placeholder {
		color: #999;
		font-size: 15px;
	}
	
	.center button {
		background: #F3961F;
		width: 100%;
		height: 45px;
		border-radius: 10px;
		font-size: 18px;
		color: #FCFCFC;
		margin-top: 58px;
	}
</style>